import { IncomeDao } from './../dao/incomeDao'
import { IamInfo } from '../controller/iamInfo'
import { Income } from '../model/income'
import { ResponseList } from '../model/responseList'
export class IncomeService {
  private readonly incomeDao = new IncomeDao()
  queryIncomeList(params: any): Promise<ResponseList<Income>> {
    params.creator = IamInfo.id
    return this.incomeDao.queryIncomeList(params).then(modelData=>{
      return this.incomeDao.count(params).then(count => {
        const responseList = new ResponseList<Income>();
        responseList.list=modelData
        responseList.count = count
        return responseList
      })
    })
  }
  upsertIncome(params: any): Promise<any> {
    params.creator = IamInfo.id
    params.updater = IamInfo.id
    return this.incomeDao.upsertIncome(params)
  }
  deleteIncome(params: any): Promise<number> {
    return this.incomeDao.deleteIncome(params)
  }
}